package com.nf.health.app.inquiry.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.nf.health.app.R;
import com.nf.health.app.inquiry.impl.bindviewhl.DocType;
import com.nf.health.app.inquiry.impl.viewholder.DoctorCommentViewHolder;
import com.nf.health.app.models.DoctorCommnetVo;

import java.util.List;

/**
 * Created by Jason on 2016/9/23.
 */
public class DocCommentListRcyAdapter extends RecyclerView.Adapter {
    private Context cnt ;
    private int viewMyType = 1;
    private LayoutInflater  layoutInflater;
    private  List<DoctorCommnetVo> doctorCommnetVoLis;
    public  DocCommentListRcyAdapter(Context cnt){
       this.cnt = cnt;
       layoutInflater = LayoutInflater.from(cnt);
   }

    /**
     * 刷新功能 医生的评价
     * @param
     */
    public void setDoctorCommentData(List<DoctorCommnetVo> doctorCommnetVoList){
        this.doctorCommnetVoLis =doctorCommnetVoList;
        notifyItemChanged(viewMyType);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//        if(viewType == viewMyType){
            View viewAds = layoutInflater.inflate(R.layout.view_comment_list, null);//评论列表
            return  new DoctorCommentViewHolder(viewAds,cnt,layoutInflater);
//        }
//        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//        if(holder instanceof DoctorCommentViewHolder){
            DoctorCommentViewHolder doctorCommentViewHolder = (DoctorCommentViewHolder) holder;
            DoctorCommnetVo doctorCommnetVo =doctorCommnetVoLis.get(position);
            doctorCommentViewHolder.reFreshMyTvText(doctorCommnetVo);
//        }
    }

    @Override
    public int getItemViewType(int position) {
        return viewMyType;
    }

    @Override
    public int getItemCount() {
        if(doctorCommnetVoLis== null){
            return 0;
        }
        return doctorCommnetVoLis.size();
    }
}
